package com.demo.config;

import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Slf4j
@Configuration
@EnableSwagger2
public class Swagger2Config {
    @Bean
    public Docket createRestApi() {
        log.debug("---createRestApi---");
        return new Docket(DocumentationType.SWAGGER_2)
                .enable(true)
                .groupName("v1")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.demo.web"))//api接口包扫描路径
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
//                .paths(or(regex("/api.*")))
                .build();
    }

}